<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        body{
            background-color: pink;
        }
        #nav{
            width: 900px;
            height: 63px;
            background: url("images/doubleOne.png") no-repeat right center #FFFFFF;
            border-radius: 5px;
            position: relative;
            margin: 100px auto ;
        }
        #nav ul{
            position: relative;
        }
        #nav ul li{
            float: left;
            width: 88px;
            height: 63px;
            text-align: center;
            line-height: 70px;
            cursor: pointer;
        }
        #t_mall{
            width: 88px;
            height: 63px;
            background: url("images/tMall.png") no-repeat;
            position: absolute;
        }
    </style>
</head>
<body>
<div id="nav">
    <span id="t_mall"></span>
    <ul>
        <li>双11狂欢</li>
        <li>服装会场</li>
        <li>数码家电</li>
        <li>家具建材</li>
        <li>母婴童装</li>
        <li>手机会场</li>
        <li>美妆会场</li>
        <li>进口会场</li>
        <li>飞猪旅行</li>
    </ul>
</div>
<script>
    window.onload=function () {
      var nav = document.getElementById("nav");
      var t_mall = nav.children[0];
      var ul = nav.children[1];
      var AllLis = ul.children;

      var beginX = 0;
      for(var i=0;i<AllLis.length;i++){
          var li = AllLis[i];
          li.onmouseover=function () {

              end = this.offsetLeft;
          };
          li.onmouseout=function () {
              //console.log("离开")
              end = beginX;
          }
          li.onmousedown=function () {
              //console.log("按下")
              beginX = this.offsetLeft;
          }
      }
        var begin = 0, end =0;
        setInterval(function () {
            begin = begin + (end - begin) * 0.1;
            t_mall.style.left = begin + "px";
        }, 10);
    };
</script>
</body>
</html>